   package com.bjsxt.web.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bjsxt.commons.DataGridModel;
import com.bjsxt.commons.MedicineModel;
import com.bjsxt.pojo.Drug;
import com.bjsxt.service.MedicineMessageService;

/**
 * 药品管理的控制器
 * @author clw
 *
 */
@Controller
@RequestMapping("/medicine")
public class MedicineController {
	@Autowired
	private MedicineMessageService medicineMessageService;
	
	@RequestMapping("/showMedicineMessage")
	@ResponseBody
	public DataGridModel showMedine(int page,int rows){
		
		return this.medicineMessageService.showMedicine(page, rows);
	}
	
	@RequestMapping("/modifyMedicineMessage")
	@ResponseBody
	public Integer modifyMedicineMessage(Drug drug) {
		try {
			medicineMessageService.updateMedicine(drug);
			return 200;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return 500;
		}
	}
	
	@RequestMapping("/dropMedicineMessage")
	@ResponseBody
	public Integer dropMedicineMessage(Integer drugid) {
		try {
			medicineMessageService.dropMedicineMessage(drugid);
			return 200;
		} catch (Exception e) {
			e.printStackTrace();
			return 500;
		}

	}
}
